package org.miradi.diagram.coalescer;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import org.miradi.objects.DiagramFactor;

public class NodeManager
{
	public static void reset()
	{
		diagramToNode.clear();
		nodes.clear();
		
	}

	public static Node get(final DiagramFactor factor) {
		Node node = diagramToNode.get(factor);
		if (null==node) {
			node = new Node(factor);
			diagramToNode.put(factor, node);
			nodes.add(node);
		}
		return node;
	}
	
	public static Set<Node> getNodes()
	{
		return nodes;
	}
	
	public static boolean allNodesGrouped()
	{
		for (Node node : nodes) {
			if (!node.isGrouped())
				return false;
		}
		return true;
	}
	
	
	private static final Map<DiagramFactor, Node> diagramToNode  = new HashMap<DiagramFactor, Node>();
	private static final Set<Node> nodes  = new HashSet<Node>();
}
